
package com.cong.timesheet.service;

import com.cong.timesheet.model.User;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Sunil
 */
public class UserService {

    private static List<User> users = new ArrayList<User>();
    static{
        users.add(new User(1, "sun", "123456", "Sunil", "Singh", "sks.256@gmail.com"));
        users.add(new User(2,"maha","123456","mahalakshmi","murugan","mahalakshmi.m@logiwareinc.com"));
        users.add(new User(3,"sathya","123456","sathyapriya","sathiyavelu","sathiyapriya.s@logiwareinc.com"));
        users.add(new User(4,"mohana","123456","mohanapriya","subramanian","mohanapriya.a@logiwareinc.com"));
        users.add(new User(5,"kala","123456","kalavathi","deivanayagam","kalavathi.d@logiwareinc.com"));
        users.add(new User(6,"rajesh","rajesh123","rajesh","shivanathasamy","rajesh.s@logiwareinc.com"));
    }
    public boolean checkLogin(String userName, String password){
        if(userName != null && password != null){
            for(User user: users){
                if( userName.equals(user.getUserName()) && password.equals(user.getPassword())){
                    return true;
                }
            }
            return false;
        }else{
            return false;
        }
    }   
    
    public void addUser(User user){
        users.add(user);
    }
            
    public User getUser(int id){
        int index = users.indexOf(new User(id));
        return users.get(index);
    }
    
    public List<User> getUsers(){
        return users;
    }
}
